define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'authuser/index',
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: 'authuser/multi',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'userId',
                sortName: 'userId',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'userId', title: __('UserId'),operate:false},
                        {field: 'phone', title: __('Phone')},
                        //{field: 'password', title: __('Password')},
                        //{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
                        //{field: 'forbidden', title: __('Forbidden')},
                        //{field: 'payPassword', title: __('PayPassword')},
                        //{field: 'jxAccount', title: __('JxAccount')},
                        //{field: 'cardType', title: __('CardType')},
                        //{field: 'idCard', title: __('IdCard')},
                        {field: 'name', title: __('Name'),operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', style: 'width:200px'},

                        {field: 'createTime', title: __('CreateTime'),formatter: Table.api.formatter.datetime,operate:false},
                        {field: 'renzheng', title: __('Renzheng'),operate:false},
                        {field: 'openTime', title: __('OpenTime'), formatter: Table.api.formatter.datetime,operate:false},
                        {field: 'bank', title: __('bank'),operate:false},
                        {field: 'bankTime', title: __('bankTime'),operate:false},



                        {field: 'kaihu', title: __('kaihu'),operate:false},
                        {field: 'openTime', title: __('KaihuTime'), formatter: Table.api.formatter.datetime,operate:false},
                        //{field: 'sex', title: __('Sex')},
                        //{field: 'email', title: __('Email')},
                        //{field: 'company', title: __('Company')},
                        //{field: 'accessId', title: __('AccessId')},
                        //{field: 'accessKey', title: __('AccessKey')},
                      //  {field: 'desKey', title: __('DesKey')},
                        //{field: 'device', title: __('Device')},
                        //{field: 'deviceId', title: __('DeviceId')},
                        {field: 'promotion', title: __('Promotion'),operate:false},
                        //{field: 'createTime', title: __('CreateTime'), formatter: Table.api.formatter.datetime},
                        //{field: 'openTime', title: __('OpenTime'), formatter: Table.api.formatter.datetime},
                        //{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                search: false,
                //启用普通表单搜索
                commonSearch: true,
                //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                searchFormVisible: false
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});